﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class DatvePage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnDatve_Click(object sender, EventArgs e)
    {
        //QLVe ql = new QLVe();
        Ve v = new Ve();
        v.Ngaylap = DateTime.Now;
        v.Machuyen = Int32.Parse(Session["cid"].ToString());
        v.Makh = Session["username"].ToString();
        v.Hinhthucthanhtoan = "Trực Tiếp";
        v.Trangthai = "Đã Đặt";
        v.Nguoithanhtoan = txtNguoithanhtoan.Text;
        datve(v);
        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "CheckLogin", "alert('Quý khách đã đặt vé thành công!!!')", true);
        
    }

    public void datve(Ve ve)
    {
        ConnectionDB cn = new ConnectionDB();
        cn.Cmd.Parameters.Add(new SqlParameter("@1", ve.Ngaylap));
        cn.Cmd.Parameters.Add(new SqlParameter("@2", ve.Machuyen));
        cn.Cmd.Parameters.Add(new SqlParameter("@3", ve.Makh));
        cn.Cmd.Parameters.Add(new SqlParameter("@4", ve.Hinhthucthanhtoan));
        cn.Cmd.Parameters.Add(new SqlParameter("@5", ve.Trangthai));
        cn.Cmd.Parameters.Add(new SqlParameter("@6", ve.Nguoithanhtoan));
        cn.Cmd.CommandType = CommandType.StoredProcedure;
        cn.Cmd.CommandText = "datve";
        cn.Cmd.ExecuteNonQuery();
    }
}